//
//  HeaderLabel.m
//  gdemm
//
//  Created by 乔明超 on 2017/8/15.
//  Copyright © 2017年 Goldencis. All rights reserved.
//

#import "HeaderLabel.h"
#import "Masonry.h"
#import "Utils.h"
@interface HeaderLabel()
@property(strong,nonatomic) UIView *lineView;

@end
@implementation HeaderLabel


- (instancetype)init
{
    self = [super init];
    if (self) {
        [self setUI];
    }
    return self;
}
- (void)setUI{
    UIView *lineView = [[UIView alloc]init];
    self.lineView = lineView;
    lineView.backgroundColor = [Utils UIColorFromHex:0xaaaaaa];
    [self addSubview:lineView];
    
    UILabel *textLabel = [[UILabel alloc]init];
    self.textLabel = textLabel;
    [textLabel setTextColor:[Utils UIColorFromHex:0x555555]];
    textLabel.font = [UIFont systemFontOfSize:16];
    [self addSubview:textLabel];

}


- (void)layoutSubviews{

    [super layoutSubviews];
    
    CGFloat height = [self.textLabel.text boundingRectWithSize:CGSizeMake(WINDOWWIDTH, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:16]} context:nil].size.height;

    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.width.mas_equalTo(4);
        make.height.mas_equalTo(height);
        make.centerY.mas_equalTo(self);
    }];
    
    [self.textLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.lineView.mas_right).offset(16);
        make.right.mas_equalTo(0);
        make.height.mas_equalTo(height);
        make.centerY.mas_equalTo(self);
    }];
   
}
@end
